#include "otherparameter.h"
#include<QtSql>
#include <string>
#include<iostream>
#include"dbutil.h"
using namespace std;
OtherParameter ::OtherParameter(QObject *parent):
    QObject(parent)
{}
void OtherParameter::updateParameter(QString atmosPress,QString atmosPara)
{
    Dbutil db;
    QSqlDatabase data;
    data=db.connect();
    QSqlQuery update;
    string press=atmosPress.toStdString();
    string para=atmosPara.toStdString();
    string sql = "UPDATE  other_parameter set atoma_press="+press+
            ",atmos_para="+para+" where id=1";
    const char *k = sql.c_str();
     bool success = update.exec(k);
    if(success)  {

         qDebug()<<"upadte success";
    }
    else qDebug()<< "fail";
    db.dbclose(data);
}

void  OtherParameter::selectParameter()
{
    Dbutil db;
    QSqlDatabase data;
    data=db.connect();
    QSqlQuery query;
    string sql="select *from other_parameter ";
    const char *k = sql.c_str();
    bool success = query.exec(k);
    if(success)  {
       query.next();
//         while(query.next()) qDebug()<<query.value().toString();
       atmos_press=query.value(1).toString();
       atmos_para=query.value(2).toString();

    }
    else qDebug()<< "fail";
db.dbclose(data);
}
QString OtherParameter::getatmos_press()
{
    return atmos_press;
}
QString OtherParameter::getatmos_para()
{
    return atmos_para;
}

